#include<iostream>
using namespace std;

class Solution {
public:
    bool firstMoveWin(int n) {
        if(n <= 4) {
            //n == 0 或者 2 后手赢
            return (n == 0 || n == 2) ? false : true;
        }
        int eat = 1;
        while(n - eat >= 0) {
            if(!this->firstMoveWin(n - eat)) {
                //后手输了 那么先手赢了
                return true;
            }
            eat *= 4;
        }
        return false;
    }

    void printTable() {
        //打表发现0~n 后先后先先规律
        for(int i = 0; i < 50; i++) {
            if(this->firstMoveWin(i)) {
                cout << "i:" << i << "\t" << "先" << endl;
            } else {
                cout << "i:" << i << "\t" << "后---" << endl;
            }
        }
    }

    //先手赢 根据打表结果直接输出代码
    void f_win(int n) {
        if(n < 0) {
            cout << "非法输入" << endl;
        }
        if(n % 5 == 0 || n % 5 == 2) {
            cout << "后手胜利" << endl;
        } else {
            cout << "先手胜利" << endl;
        }
        
    }
};

int main() {
    Solution().printTable();
    return 0;
}